package com.zdp.filesync.nacos.service;

import com.zdp.filesync.nacos.vo.NamespaceVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@FeignClient(value = "nacos",url = "${nacos.config.server-addr:http://127.0.0.1:8848}")
public interface NacosApi {


    @GetMapping("/nacos/v1/cs/configs")
    String getConfig(@RequestParam(required = false)String tenant,
                     @RequestParam String dataId,
                     @RequestParam String group);

    /**
     * 推送配置
     * @param tenant 租户信息，对应Nacos的命名空间Id字段
     * @param dataId
     * @param group
     * @param content
     * @param type
     * @return
     */
    @PostMapping("/nacos/v1/cs/configs")
    boolean pushConfig(@RequestParam(required = false) String tenant,
                              @RequestParam String dataId,@RequestParam String group,@RequestParam String content,
                              @RequestParam(required = false) String type);


    /**
     * 创建命名空间
     * @param customNamespaceId
     * @param namespaceName
     * @param namespaceDesc
     * @return
     */
    @PostMapping("/nacos/v1/console/namespaces")
    boolean createNamespace(@RequestParam String customNamespaceId , @RequestParam String namespaceName,
                            @RequestParam(required = false)String namespaceDesc);

    @GetMapping("/nacos/v1/console/namespaces")
    NamespaceVO searchNamespace();
}
